package com.tj.bo.user.server.dao.impl;
import com.fqgj.common.base.AbstractBaseMapper;
import com.tj.bo.user.server.dao.UserPromotionMappingInfoDao;
import com.tj.bo.user.server.entity.UserPromotionMappingInfoEntity;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.Map;

/**
* User: xulin
* Date: 2020-08-19
* Time: 18:16:04.880
*/

@Repository
public class UserPromotionMappingInfoDaoImpl extends AbstractBaseMapper<UserPromotionMappingInfoEntity> implements UserPromotionMappingInfoDao {

    @Override
    public UserPromotionMappingInfoEntity queryUserPromotionInfoByInviteCode(String inviteCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("inviteCode", inviteCode);
        return getSqlSession().selectOne(this.getStatement("queryUserPromotionInfoByInviteCode"), params);
    }

    @Override
    public UserPromotionMappingInfoEntity queryUserPromotionInfoByUserId(Long userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        return getSqlSession().selectOne(this.getStatement("queryUserPromotionInfoByUserId"), params);
    }

    @Override
    public UserPromotionMappingInfoEntity queryUserPromotionInfoByUserCode(String userCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCode", userCode);
        return getSqlSession().selectOne(this.getStatement("queryUserPromotionInfoByUserCode"), params);
    }

    @Override
    public int updateUserPromotionInfo(Long userId, Integer inviteNum, Integer bonus) {
        Map<String, Object> params = new HashMap<>();
        params.put("userId", userId);
        params.put("inviteNum", inviteNum);
        params.put("bonus", bonus);
        return getSqlSession().update(this.getStatement("updateUserPromotionInfo"), params);
    }

    @Override
    public int updateUserPromotionInfoByUserCode(String userCode, Integer inviteNum, Integer bonus) {
        Map<String, Object> params = new HashMap<>();
        params.put("userCode", userCode);
        params.put("inviteNum", inviteNum);
        params.put("bonus", bonus);
        return getSqlSession().update(this.getStatement("updateUserPromotionInfoByUserCode"), params);
    }
}